/**
 * @file entry
 * @author *__ author __*{% if: *__ email __* %}(*__ email __*){% /if %}
 */

import Vue from 'vue';
import Meta from 'vue-meta';
import ElementUI from 'element-ui';
import VueI18n from 'vue-i18n';
import VueContextMenu from 'vue-contextmenu';
import vueTouch from 'kim-vue-touch';

import '@/assets/css/base.css';
import '@/assets/css/common.css';
import 'element-ui/lib/theme-chalk/index.css';
import '@/assets/elementUI/theme/index.css';
import '@/assets/icons';
import filters from '@/utils/filters';
import colorPicker from '@villin/u-com'
import {
  createRouter,
} from '@/.lavas/router';
import {
  createStore,
} from '@/.lavas/store';
import AppComponent from './App.vue';
import udsUi from 'uds-ui';


String.prototype.trim = function (char, type) {
  if (char) {
    if (type == 'left') {
      return this.replace(new RegExp(`^\\${char}+`, 'g'), '');
    } if (type == 'right') {
      return this.replace(new RegExp(`\\${char}+$`, 'g'), '');
    }
    return this.replace(new RegExp(`^\\${char}+|\\${char}+$`, 'g'), '');
  }
  return this.replace(/^\s+|\s+$/g, '');
};

Vue.use(Meta);
Vue.use(ElementUI);
Vue.use(VueI18n);
Vue.use(filters);
Vue.use(VueContextMenu);
Vue.use(vueTouch);
Vue.use(colorPicker)
Vue.use(udsUi)
Vue.config.productionTip = false;

const i18n = new VueI18n({
  locale: 'cn', // 将要切换的语言，可以通过url拼的参数获取，用户行为select选择获取，本地manifest配置获取等，根据场景动态获取
  messages: {
    cn: require('../assets/languages/cn.json'), // 本地资源文件，我这里配2个语言，中文&英文，src下根据个人情况放置
  },
});

export function createApp() {
  const router = createRouter();
  const store = createStore();
  const App = Vue.extend({
    router,
    i18n,
    store,
    ...AppComponent,
  });
  return {
    App,
    router,
    store,
  };
}

if (module.hot) {
  module.hot.accept();
}
